Repository navigation
mcpx(v2 plugin): answer sampling via ctx.generate.text (#2841) - #4997
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 43 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Implements #2841 item (4) of the #1858 SET-REMAINDER: the mcpx OpenCode v2 plugin can now answer MCP sampling requests.
What
mcpx relays a server's
sampling/createMessageto its broker as a sample-mode question routed to the agent audience — but the v2 plugin never looked at those rows, so every sampling request sat until its 120s TTL expired and the upstream heard an internal error.pkgs/mcpx/plugin/opencode/v2/sampling.ts: a watcher polls the daemon's elicit list (5s, inside the 120s sample TTL) for sample-mode, agent-audience rows, flattens the CreateMessageRequest params stored in the row'srequestedSchemato a plain prompt (system prompt first, then message text blocks labelled by role; non-text blocks named, not dropped), callsctx.generate.text, and answers the row with a CreateMessageResult (role: "assistant", model = first model-preference hint or the generate label, one text block,stopReason: "endTurn") — the shape the broker'sValidateSampleResultaccepts.tools/toolChoiceare left open for another answerer:ctx.generate.textis a plain prompt→text completion (pinned v2 protocol generate group; PLG-33 indocs/compare/register/plugin-apis.md) and cannot honour tool use. This is the closest supported equivalent on the pinned surface, recorded here and on mcpx opencode v2 plugin: implement the #1858 SET-REMAINDER items (1)-(5) #2841/mcpx: port the opencode plugin to opencode v2 (a rewrite, and several things get better) #1858 per the task's acceptance terms.index.ts:McpxV2Contextgains the optionalgeneratedomain; setup starts the watcher when the host offers it and returns its stop as the setup cleanup.options.ts: new plugin optionanswerSampling(default on; plugin-option only — no env name, per the settings guard).Tests
On the laptop (worktree from origin/main):
bun test plugin/opencode/v2/— 48 pass, 0 fail (10 new sampling tests: prompt flattening, tools refusal, the generate→answer round-trip incl. the{data:{text}}envelope, failure leaves the row open, no-daemon no-throw).bun test plugin/— 101 pass, 5 skip, 0 fail.TestThePluginReadsNoUndeclaredSettingpasses.TestTheScriptEnvironmentIsWhatTheCodeSetsfails identically on clean main (pre-existing, Go-side ScriptEnv declarations; untouched by this PR).Queue task 3997. Refs #2841, #1858.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.